/**
 * First we will load all of this project's JavaScript dependencies which
 * includes Vue and other libraries. It is a great starting point when
 * building robust, powerful web applications using Vue and Laravel.
 */

require('./bootstrap');

/**
 * Blog Javascript 顶格固定栏是否显现
 * Copied from Clean Blog v1.0.0 (http://startbootstrap.com)
 */
jQuery(document).ready(function ($) {
    var MQL = 1170;

    if ($(window).width() > MQL) {
        var headerHeight = $('.navbar-custom').height()
        $(window).on('scroll', {
                previousTop: 0
            },
            function () {
                var currentTop = $(window).scrollTop()

                if (currentTop < this.previousTop) {
                    if (currentTop > 0 && $('.navbar-custom').hasClass('is-fixed')) {
                        $('.navbar-custom').addClass('is-visible');
                    } else {
                        $('.navbar-custom').removeClass('is-visible is-fixed');
                    }
                } else {
                    $('.navbar-custom').removeClass('is-visiable')
                    if (currentTop > headerHeight && !$('.navbar-custom').hasClass('is-fixed')) {
                        $('.navbar-custom').addClass('is-fixed')
                    }
                }
                this.previousTop = currentTop;
            }
        )
    }

    // Initialize tooltips
    $('[data-toggle="tooltip"]').tooltip();
})
